using Aluetjen.EmailService.Domain.Models.Message;
using log4net;

namespace Aluetjen.EmailService.Domain.Gateways
{
    public class Log4NetGateway : IGatewayImpl
    {
        private ILog _mailLogger;
        
        public void Configure(string connectionString)
        {
            _mailLogger = LogManager.GetLogger(typeof(Log4NetGateway) + "." + connectionString);
        }

        public void Send(MailMessage message)
        {
            if(_mailLogger == null)
            {
                _mailLogger = LogManager.GetLogger(typeof (Log4NetGateway));
            }

            _mailLogger.InfoFormat("{0}\t{1}\t{2}", string.Join(";",message.From), string.Join(";", message.To), message.Subject);
        }
    }
}